home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdio.h>
- #include "MonthOverview.h"
- #include "OverviewDay.h"
- #include "VCal.h"
- #include "Preferences.h"
- #include <Vk/VkMenuBar.h>
- #include <Vk/VkMenuItem.h>
- #include <Vk/VkHelpPane.h>
-
- #include <Sgm/Grid.h>
- #include <Xm/Form.h>
- #include <Xm/LabelG.h>
- #include <Xm/ToggleBG.h>
-
- static int count;
- static Arg args[10];
-
- /**********************************************************************/
-
- MonthOverview::MonthOverview(VCal *o, const char *docName)
- : VkWindow(docName)
- {
- owner = o;
-
- grid = NULL;
- month = year = 0;
- restricted = thePreferences->restricted();
- }
-
- MonthOverview::~MonthOverview()
- {
- int each;
-
- if (grid) {
- for (each=0; each<NUM_SPOTS; each++) {
- delete days[each];
- }
- }
- }
-
- const char *
- MonthOverview::className()
- {
- return "MonthOverview";
- }
-
- /**********************************************************************/
-
- void
- MonthOverview::selectMonth(int m, int y)
- {
- int each, weekday, max;
- int nowDay, nowMonth, nowYear;
- Boolean today;
- char str[256];
- XmString xs;
-
- month = m;
- year = y;
- owner->getToday(&nowDay, &nowMonth, &nowYear);
- weekday = computeWeekday(1, month, year);
- max = NumberOfDays(month, year);
- if (grid) {
- formatDate(month, year, str);
- xs = XmStringCreateSimple(str);
- count = 0;
- XtSetArg(args[count], XmNlabelString, xs); count++;
- XtSetValues(monthLabel, args, count);
- XmStringFree(xs);
-
- for (each=0; each<NUM_SPOTS; each++) {
- if (each < weekday-1 ||
- each-weekday+2 > max) {
- days[each]->setDate(0, 0, 0);
- } else {
- today = (month == nowMonth && year == nowYear &&
- each-weekday+2 == nowDay);
- if (restricted) {
- days[each]->setDate(each-weekday+2, m, y, today,
- thePreferences->restrictStart()*MINS_IN_HOUR,
- thePreferences->restrictStop()*MINS_IN_HOUR);
- } else {
- days[each]->setDate(each-weekday+2, m, y, today);
- }
- }
- }
- }
- }
-
- /**********************************************************************/
-
- Widget
- MonthOverview::setUpInterface(Widget parent)
- {
- int each;
-
- fileMenu();
- if (menu()->helpPane()) {
- menu()->helpPane()->setItemSensitivities(False, True, False, False,
- False);
- }
-
- count = 0;
- form = XmCreateForm(parent, "form", args, count);
-
- count = 0;
- XtSetArg(args[count], XmNtopAttachment, XmATTACH_FORM); count++;
- XtSetArg(args[count], XmNleftAttachment, XmATTACH_FORM); count++;
- XtSetArg(args[count], XmNrightAttachment, XmATTACH_FORM); count++;
- monthLabel = XmCreateLabelGadget(form, "monthLabel", args, count);
- XtManageChild(monthLabel);
-
- count = 0;
- XtSetArg(args[count], XmNnumColumns, 7); count++;
- XtSetArg(args[count], XmNnumRows, 6); count++;
- XtSetArg(args[count], XmNtopAttachment, XmATTACH_WIDGET); count++;
- XtSetArg(args[count], XmNtopWidget, monthLabel); count++;
- XtSetArg(args[count], XmNbottomAttachment, XmATTACH_FORM); count++;
- XtSetArg(args[count], XmNleftAttachment, XmATTACH_FORM); count++;
- XtSetArg(args[count], XmNrightAttachment, XmATTACH_FORM); count++;
- grid = SgCreateGrid(form, "grid", args, count);
- XtManageChild(grid);
-
- for (each=0; each<NUM_SPOTS; each++) {
- days[each] = new OverviewDay("overviewDay", grid, owner);
- days[each]->show();
- }
- updateDisplay();
-
- XtManageChild(form);
- return form;
- }
-
- void
- MonthOverview::handleWmDeleteMessage()
- {
- doQuit();
- }
-
- void
- MonthOverview::fileMenu()
- {
- VkSubMenu* menu = addMenuPane("monthOverviewFileMenu");
- VkMenuToggle *item;
-
- item = menu->addToggle("restrictedToggleMenuItem",
- MonthOverview::restricted_menu,
- (XtPointer) this);
- item->setVisualState(thePreferences->restricted());
- menu->addSeparator();
- menu->addAction("monthOverviewQuitMenuItem",
- MonthOverview::quit_menu,
- (XtPointer) this);
- }
-
- void
- MonthOverview::doQuit()
- {
- hide();
- }
-
- void
- MonthOverview::restrictedChanged(Boolean r)
- {
- if (restricted != r) {
- restricted = r;
- updateDisplay();
- }
- }
-
- /************************************************************/
-
- void
- MonthOverview::quit_menu(Widget, XtPointer client_data, XtPointer)
- {
- MonthOverview *obj = (MonthOverview *) client_data;
-
- obj->doQuit();
- }
-
- void
- MonthOverview::restricted_menu(Widget w, XtPointer client_data, XtPointer)
- {
- MonthOverview *obj = (MonthOverview *) client_data;
-
- obj->restrictedChanged(XmToggleButtonGadgetGetState(w));
- }
-
-